package addEmployeeTransaction;

import java.util.Date;

import main.Paycheck;
import methods.PaymentMethod;

import affiliation.Affiliation;
import affiliation.NoAffiliation;
import schedule.PaymentSchedule;
import classification.PaymentClassification;

public class Employee {

	private int empid;
	private String name;
	private String address;
	private PaymentClassification classification;
	private PaymentSchedule schedule;
	private PaymentMethod method;
	private Affiliation affiliation = new NoAffiliation();

	public Employee(int empid, String name, String address) {
		this.empid = empid;
		this.name = name;
		this.address = address;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public String getAddress() {
		return address;
	}

	public PaymentClassification getClassification() {
		return classification;
	}

	public void setClassification(PaymentClassification classification) {
		this.classification = classification;
	}

	public PaymentSchedule getSchedule() {
		return schedule;
	}

	public void setSchedule(PaymentSchedule schedule) {
		this.schedule = schedule;
	}

	public PaymentMethod getMethod() {
		return method;
	}

	public void setMethod(PaymentMethod method) {
		this.method = method;
	}

	public Affiliation getAffiliation() {
		return affiliation;
	}

	public void setAffiliation(Affiliation affiliation) {
		this.affiliation = affiliation;
	}

	public boolean isPayDate(Date date) {
		return schedule.isPayDate(date);
	}

	public void payday(Paycheck paycheck) {
		double grossPay = classification.calculatePay(paycheck);
		double deductions = affiliation.calculateDeductions(paycheck);
		double netPay = grossPay - deductions;
		paycheck.setGrossPay(grossPay);
		paycheck.setDeductions(deductions);
		paycheck.setNetPay(netPay);
		method.Pay(paycheck);
	}

	public Date getPayPeriodStartDate(Date date) {
		return schedule.getPayPeriodStartDate(date);
	}

	public int getEmpId() {
		return empid;
	}

	public String toString() {
		return "Emp#: " + empid + "   " + name + "   " + address + "   "
				+ "Paid " + classification + " " + schedule + " by " + method;
	}
}
